//深拷贝
export default function clone(any){
  if(checkType(any) === 'Object') { // 拷贝对象
      const o = {};
      for(const key in any) {
          o[key] = clone(any[key])
      }
      return o;
  } else if(checkType(any) === 'Array') { // 拷贝数组
      const arr = []
      for(let i = 0,leng = any.length;i<leng;i++) {
          arr[i] = clone(any[i])
      }
      return arr;
  } else if(checkType(any) === 'Function') { // 拷贝函数
      return new Function('return '+any.toString()).call(this)
  } else if(checkType(any) === 'Date') { // 拷贝⽇期
      return new Date(any.valueOf())
  } else if(checkType(any) === 'RegExp') { // 拷贝正则
      return new RegExp(any)
  } else if(checkType(any) === 'Map') { // 拷贝Map 集合
    const m = new Map()
      any.forEach((v,k)=>{
          m.set(k, clone(v))
      })
      return m
  } else if(checkType(any) === 'Set') { // 拷贝Set 集合
    const s = new Set()
      for(const val of any.values()) {
          s.add(clone(val))
      }
      return s
  }
  return any;
}
//校验类型
function checkType(any){
  return Object.prototype.toString.call(any).slice(8,-1)
}

export function getColorByCrop(any){
	let obj = {
		colorset:'rgba(112,128,144,1)',
		colorfill:'rgba(112,128,144,0.4)'
	}
	if(any.indexOf('陵两优171')>-1){
		obj.colorset = 'rgba(158,244,145,1)'
		obj.colorfill = 'rgba(158,244,145,0.4)'
	}else if(any.indexOf('荃优粤农丝苗')>-1){
		obj.colorset = 'rgba(253,244,53,1)'
		obj.colorfill = 'rgba(253,244,53,0.4)'
	}else if(any.indexOf('甬籼15')>-1){
		obj.colorset = 'rgba(4,206,255,1)'
			obj.colorfill = 'rgba(4,206,255,0.4)'
	}else if(any.indexOf('臻两优钰占')>-1){
		obj.colorset = 'rgba(144,123,18,1)'
			obj.colorfill = 'rgba(144,123,18,0.4)'
	}else if(any.indexOf('荃两优粤农丝苗')>-1){
		obj.colorset = 'rgba(70,46,255,1)'
			obj.colorfill = 'rgba(70,46,255,0.4)'
	}else if(any.indexOf('泰优398')>-1){
		obj.colorset = 'rgba(210,45,243,1)'
			obj.colorfill = 'rgba(210,45,243,0.4)'
	}else if(any.indexOf('紫两优')>-1){
		obj.colorset = 'rgba(211,161,38,1)'
			obj.colorfill = 'rgba(211,161,38,0.4)'
	}else if(any.indexOf('臻两优5438')>-1){
		obj.colorset = 'rgba(204,102,0,1)'
			obj.colorfill = 'rgba(204,102,0,0.4)'
	}else if(any.indexOf('陵两优171(中稻）')>-1){
		obj.colorset = 'rgba(0,153,51,1)'
			obj.colorfill = 'rgba(0,153,51,0.4)'
	}else if(any.indexOf('巧两优超占')>-1){
		obj.colorset = 'rgba(255,46,189,1)'
			obj.colorfill = 'rgba(255,46,189,0.4)'
	}
  return obj
}